var eventproxy=require('eventproxy');
var ep=new eventproxy();
function mockReadFile(filename,cb){
    setTimeout(function () {
        cb(null,filename.substring(0,filename.indexOf('.')));
    },Math.random()*1000|0);
}


//--------------------------------

var files=['file_1.txt','file_2.txt','file_3.txt'];

ep.after('got_file',files.length,function (list) {
    console.log('list:',list);
});

for(var i=0;i<files.length;i++){
    mockReadFile(files[i], function (err,data) {
        ep.emit('got_file',data);
    });
}


